package com.cmcc.aregister.ui.adapter;

import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.cmcc.aregister.R;

public class DepAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<String> depList;

    public DepAdapter(Context context, ArrayList<String> depList) {
        this.context = context;
        this.depList = depList;
    }

    static class ViewHolder {
        TextView title;
    }

    @Override
    public int getCount() {
        return depList.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(
                R.layout.text_line, null);
            holder.title = (TextView) convertView.findViewById(R.id.title);
            convertView.setTag(holder);
        }
        else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.title.setText(depList.get(position));
        return convertView;
    }
}